import mock from 'mockjs'

const getList = mock.mock(
  'getList',
  'post',
  options => {
    const scoreData = mock.mock({
      'list|35': [{
        name: '@ctitle(10, 25)',
        score: '@integer(300, 5000)',
        'status|1': [1, 2]
      }]
    })
    const {
      pageNum,
      pageSize
    } = JSON.parse(options.body)
    const {
      list
    } = scoreData
    if (pageNum * pageSize >= list.length) {
      return {
        success: 'true',
        data: {
          total: list.length,
          list: list.slice((pageNum - 1) * pageSize, pageNum * pageSize)
        },
        hasMore: false
      }
    } else {
      return {
        success: 'true',
        hasMore: true,
        data: {
          total: list.length,
          list: list.slice((pageNum - 1) * pageSize, pageNum * pageSize)
        }
      }
    }
  }
)

export default getList
